#ifndef TLV_TREE_H
#define TLV_TREE_H


#define _private
#define _public


_public typedef enum TAG_TYPE{
    TAG_NONE = 0x00,
	TAG_DIR =  0x01,
	TAG_DIR_ROOT = 0x02,
	TAG_FILE = 0x04
}tag_type_t;

_private typedef struct tlv_value {
    char        data[255];
    int         len;
}tlv_value_t;

_public typedef struct tlv_node {
    _private tag_type_t          type; //TAG_DIR, TAG_FILE, TAG_DIR_ROOT...
    _private char                name[5];//"9f26" "95" ...

    _private union {
        struct tlv_node     *child;//if type is TAG_DIR
        tlv_value_t         *value;//if type is TAG_FILE
     }p;

    _private struct tlv_node     *brother;
    _private struct tlv_node     *father;
}tlv_node_t;

_public typedef struct tlv_node      *tlv_doc_t;


struct TlvMethod{
	tlv_doc_t (*Parser)(const char *src, int len);
	void	  (*Tree)(tlv_doc_t doc);
    void      (*Destory)(tlv_doc_t doc);
    tlv_doc_t (*Find)(tlv_doc_t doc, const char *tag);
};
extern const struct TlvMethod Tlv; 
#endif
